package com.android.lovely.room.chat.database

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

/**
 *
 * @author why
 * @date 2025/3/27 15:36
 */
abstract class BaseMessage(
    open var id: Int = 0,
    open val cardId: Int = 0,
    open var message: String = "",
    open var isSend: Boolean = true,
    open var unlock: Boolean = false,
) : Parcelable {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as BaseMessage

        if (id != other.id) return false
        if (cardId != other.cardId) return false
        if (message != other.message) return false
        if (isSend != other.isSend) return false
        if (unlock != other.unlock) return false

        return true
    }

    override fun hashCode(): Int {
        var result = id
        result = 31 * result + cardId
        result = 31 * result + message.hashCode()
        result = 31 * result + isSend.hashCode()
        result = 31 * result + unlock.hashCode()
        return result
    }
}

@Parcelize
data class SendTextMessage(
    override var id: Int = 0,
    override var message: String = "",
    var isSendFail: Boolean = false,
) : BaseMessage(id, 0, message, true, false)

@Parcelize
data class ReceivedTextMessage(
    override var id: Int = 0,
    override var message: String = "",
    var showEdit: Boolean = false,
    var translate: String = "",
    var translating: Boolean = false
) : BaseMessage(id, 0, message, false, false)

@Parcelize
class ImageMessage(
    override var id: Int = 0,
    override var cardId: Int = 0,
    override var message: String = "",
    override var unlock: Boolean = false,
    val point: Int = 0,
    val intimacyValue: Int = 0
) : BaseMessage(id, cardId, message, false, unlock)

@Parcelize
class RegenerateMessage(
    override var id: Int = 0,
    var bindSendMessage: BaseMessage? = null,
    var bindReceivedMessage: BaseMessage? = null,
    override var message: String = "",
) : BaseMessage(id, 0, message, false, false)

@Parcelize
class LoadingMessage(override var id: Int) : BaseMessage(id = id, isSend = false)

@Parcelize
object LoadMoreMessage : BaseMessage(id = 494156153, isSend = false)